

const path = require('path');
const staticImg = path.join(__dirname, 'static');

function SensorbitUnoBlocks(Blockly) {
    var color_sensor = "#28BFE6";




    //雨滴传感器
    Blockly.Blocks.microbit_rain = {
        init:function(){
        this.setColour(color_sensor);
        this.appendDummyInput("")
        .appendField(new Blockly.FieldImage(staticImg+"/30.Water  droplets Sensor.svg", 84, 42))
            .appendField(Blockly.Msg.MICROBIT_RAIN)
            .appendField(Blockly.Msg.MICROBIT_DIGITALPORT)
            .appendField(new Blockly.FieldDropdown([
                ['P1', "pin1"],
                ['P8', "pin8"],
                ['P12', "pin12"],
                // ['P13', "pin13"],
                // ['P15', "pin15"],
            ]),"rainDigital")
            .appendField(Blockly.Msg.MICROBIT_ANALOGPORT)
            .appendField(new Blockly.FieldDropdown([
                ['P1', "pin1"],
                ['P2', "pin2"],
                // ['P14', "pin14"],
                // ['P16', "pin16"],
            ]),"rainAnalog")
            this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
            this.setTooltip('');
        }
    };

     //雨滴传感器模拟值
     Blockly.Blocks.microbit_rainAnalog = {
        init:function(){
        this.setColour(color_sensor);
        this.appendDummyInput("")
            .appendField(new Blockly.FieldImage(staticImg+"/30.Water  droplets Sensor.svg", 84, 42))
            .appendField(Blockly.Msg.MICROBIT_RAIN)
            .appendField(new Blockly.FieldDropdown([
                ['P1', "pin1"],
                ['P2', "pin2"],
                // ['P12', "pin12"],
                // ['P14', "pin14"],
                // ['P16', "pin16"],
            ]),"rainAnalog")
            .appendField(Blockly.Msg.MICROBIT_RAINANALOG)
            this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
            this.setOutput(true, 'Number');
        this.setTooltip('');
        }
    };

      //雨滴传感器数字值
      Blockly.Blocks.microbit_rainDigital = {
        init:function(){
        this.setColour(color_sensor);
        this.appendDummyInput("")
            .appendField(new Blockly.FieldImage(staticImg+"/30.Water  droplets Sensor.svg", 84, 42))
            .appendField(Blockly.Msg.MICROBIT_RAIN)
            .appendField(new Blockly.FieldDropdown([
                ['P1', "pin1"],
                ['P8', "pin8"],
                ['P12', "pin12"],
                // ['P13', "pin13"],
                // ['P15', "pin15"],
            ]),"rainDigital")
            .appendField(Blockly.Msg.MICROBIT_RAINDIGITAL)
            this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
            this.setOutput(true, 'Boolean');
            this.setTooltip('');
        }
    };
    return Blockly;
}

module.exports = SensorbitUnoBlocks;

